package com.homedo.microservice.open.service.gateway.alert.gateway.bean.po.enhanced;

import com.homedo.common.dao.bean.po.enhanced.base.BaseEnhanced;
import com.homedo.microservice.open.service.gateway.alert.gateway.bean.enums.forrouteservice.StatusEnum4RouteService;
import com.homedo.microservice.open.service.gateway.alert.gateway.bean.po.RouteService;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;

/**
 * @author 作者 jgshun
 * @date 创建时间 2018年09月18日 11时34分40秒
 */
public class RouteServiceEnhanced extends BaseEnhanced {
    public RouteServiceEnhanced(RouteService routeService) {

        BeanUtils.copyProperties(routeService, this);

        //自动生成 细微误差自己调整

        if (routeService.getStatus() != null) {
            this.status = StatusEnum4RouteService
                    .getStatusEnumByCode(routeService.getStatus().shortValue());
        }
    }

    public RouteServiceEnhanced() {
    }

    private String id;
    private String applicationName;
    private StatusEnum4RouteService status;
    private String comment;
    private String healthUrl;
    private Date createTime;
    private Date updateTime;

    private List<RouteServiceUrlEnhanced> routeServiceUrlEnhanceds;//服务地址列表

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getApplicationName() {
        return applicationName;
    }

    public void setApplicationName(String applicationName) {
        this.applicationName = applicationName;
    }

    public StatusEnum4RouteService getStatus() {
        return status;
    }

    public void setStatus(StatusEnum4RouteService status) {
        this.status = status;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<RouteServiceUrlEnhanced> getRouteServiceUrlEnhanceds() {
        return routeServiceUrlEnhanceds;
    }

    public void setRouteServiceUrlEnhanceds(List<RouteServiceUrlEnhanced> routeServiceUrlEnhanceds) {
        this.routeServiceUrlEnhanceds = routeServiceUrlEnhanceds;
    }

    public String getHealthUrl() {
        return healthUrl;
    }

    public void setHealthUrl(String healthUrl) {
        this.healthUrl = healthUrl;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RouteServiceEnhanced that = (RouteServiceEnhanced) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (applicationName != null ? !applicationName.equals(that.applicationName) : that.applicationName != null)
            return false;
        if (status != that.status) return false;
        if (comment != null ? !comment.equals(that.comment) : that.comment != null) return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) return false;
        return routeServiceUrlEnhanceds != null ? routeServiceUrlEnhanceds.equals(that.routeServiceUrlEnhanceds) : that.routeServiceUrlEnhanceds == null;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (applicationName != null ? applicationName.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        result = 31 * result + (comment != null ? comment.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (routeServiceUrlEnhanceds != null ? routeServiceUrlEnhanceds.hashCode() : 0);
        return result;
    }
}